const std = @import("std");
const flag = @import("cmd_flag");

pub fn main() !void {
    var apa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = apa.deinit();
    const allocator = apa.allocator();
    var flag_set = try flag.init(allocator);
    var name: []const u8 = "";
    var age: usize = 0;
    try flag_set.flagVar([]const u8, &name, "name", "Bob", "Your `name`, defalue Bob");
    try flag_set.flagVar(usize, &age, "age", 18, "Your age, default 18");
    try flag_set.parsed();
    std.debug.print("name: {s}, age: {}\n", .{ name, age });
    std.debug.print("args:\n", .{});
    for (flag_set.getArgs()) |arg| {
        std.debug.print("  {s}\n", .{arg});
    }

    flag_set.setUsage(customUsage);
    try flag_set.usage();
    defer flag_set.deinit();
}

fn customUsage(flag_set: *flag.FlagSet, writer: *std.io.Writer) anyerror!void {
    try writer.print("{s} custom usage", .{ flag_set.name });
}